package com.hy.proxy.server.controller;

import com.hy.proxy.common.JsonUtils;
import com.hy.proxy.common.PathUtils;
import com.hy.proxy.server.utils.RedisUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: hy
 * @Date: Created in 2019/10/1/23:00
 * @Description:
 * @Version: 1.0
 */
@Controller
public class JumpController {

    @Resource
    private RedisUtils redisUtils;

    @RequestMapping("/test.html")
    public String toTest() {
        return "test";
    }

    @RequestMapping("/")
    public String index() {
            return "redirect:http://asdff.tpddns.cn:8888";
//        return redisUtils.insertProxy() ? "加载数据成功" : "加载数据失败";
    }

    @RequestMapping("/list")
    @ResponseBody
    public String index2() {
        return redisUtils.insertProxy() ? "加载数据成功" : "加载数据失败";
    }

    @RequestMapping("/path")
    @ResponseBody
    public String p() {

        String userDir = "user.dir：" + PathUtils.getProjectPath();
        String classPath = "/：" + PathUtils.getClassPath();
        String property = "java.class.path：" + System.getProperty("java.class.path");

        List<String> list = new ArrayList<>();
        list.add(userDir);
        list.add(classPath);
        list.add(property);

        return JsonUtils.getGson().toJson(list);

    }

}
